package com.wcity.manage.dao.mapper;

import com.wcity.manage.dao.dal.BaseMapper;
import com.wcity.manage.dao.model.Module;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.io.Serializable;
import java.util.List;

/**
 * Created by jn on 2016/12/8.
 * 模块dao
 */
@Repository
public interface ModuleMapper extends BaseMapper<Module,Serializable> {

    /**
     * 查询子模块
     * @param parentId
     * @return
     */
    List<Module> findChildren(@Param("parentId")int parentId);

    /**
     * 查询所有父级模块
     * @return
     */
    @Select(" select id,name from td_manage_module where parent_id = 0 ")
    List<Module> findParent();

    /**
     * 获取所有模块
     * @return
     */
    List<Module> findModule();

    /**
     * 获取模块名
     * @param id
     * @return
     */
    @Select(" select name from td_manage_module where id = #{id} ")
    String findName(int id);

}
